﻿@using XCode.Membership
@{
    var entity = Model as IEntity;

    var rv = entity.GetRouteKey();
}
<a data-toggle="dropdown" class="kt-shape-font-color-3">
    <i class="flaticon2-settings kt-font-hover-primary"></i>
</a>
<!--双击打开添加样式 .editcell 即可-->
<div class="dropdown-menu dropdown-menu-right">
    @if (this.Has(PermissionFlags.Update))
    {
        <a title="编辑" class="dropdown-item editcell" href="@Url.Action("Edit", rv)">
            <i class="flaticon2-edit text-primary"></i>编辑
        </a>
    }
    else if (this.Has(PermissionFlags.Detail))
    {
        <a title="查看" class="dropdown-item" href="@Url.Action("Detail", rv)">
            <i class="flaticon2-document text-primary"></i>查看
        </a>
    }
    @if (this.Has(PermissionFlags.Delete))
    {
        var fact = ViewBag.Factory as IEntityOperate;
        var fi = (fact == null || fact.Fields == null) ? null : fact.Fields.FirstOrDefault(e => e.Name.EqualIgnoreCase("Deleted", "IsDelete", "IsDeleted"));
        if (fi != null && fi.Type == typeof(Boolean) && (Boolean)entity[fi.Name])
        {
            <a title="恢复" class="dropdown-item" href="@Url.Action("Delete", rv)" data-action="action" data-confirm="确认恢复？">
                <i class="flaticon-reply text-warning"></i>恢复
            </a>
        }
        else
        {
            <a title="删除" class="dropdown-item" href="@Url.Action("Delete", rv)" data-action="action" data-confirm="确认删除？">
                <i class="flaticon-delete text-danger"></i> 删除
            </a>
        }
    }
</div>
